package ioperation;

import book.BOOK;
import book.BOOKLIST;

import java.util.Scanner;

public class RETURNOPERATION implements IOPERATION{
    public void work(BOOKLIST booklist){
        System.out.println("归还图书.....");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的书名");
        String name = scanner.nextLine();
        int current = booklist.getUsedSize();
        for (int i = 0; i < current; i++) {
            BOOK book = booklist.getBooks(i);
            if(book.getName().equals(name)){
                if(book.isBorrowed() == true){
                    book.setBorrowed(false);
                    System.out.println("归还成功");
                    return;
                }
                else{
                    System.out.println("这本书未被借出");
                    return;
                }
            }
        }
        System.out.println("未找到这本书");
    }
}